package org.puremvc.as3.multicore.utilities.unifiedloader.clients.flash
{
/*
 	PureMVC UnifiedLoader Utility
 	Copyright (c) 2008 neil manuell
  	Your reuse is governed by the Creative Commons Attribution 3.0 License
 */
	
	import flash.events.*;
	import flash.media.Sound;
	
	import org.puremvc.as3.multicore.utilities.unifiedloader.clients.LoaderClientBase;
	import org.puremvc.as3.multicore.utilities.unifiedloader.interfaces.ILoaderClientInfo;
	import org.puremvc.as3.multicore.utilities.unifiedloader.patterns.deconstructors.SoundDeconstructor;
	

	
	public class SoundClient extends LoaderClientBase
	{
		public static const NAME:String = "soundClient";
		
		private var mSound:Sound;
		
		public function SoundClient(cli:ILoaderClientInfo)
		{
			super(cli);
		}

		
		override protected function initialiseLoad():void
		{
			mSound = new Sound();
              
		}

		override protected function startLoad():void
		{
			mSound.load(this.loaderClientInfo.urlRequest, this.loaderClientInfo.soundLoaderContext)
		}
		
		override protected function prepareAsset(event:Event):void
		{
			loaderClientInfo.deconstructor = new SoundDeconstructor(mSound);
			loaderClientInfo.setAsset(mSound);
				
		}
		
		override protected function addListeners():void
		{
			mSound.addEventListener(Event.COMPLETE, loadCompleteHandler);
			mSound.addEventListener(ProgressEvent.PROGRESS, relayHandler);
			mSound.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
			mSound.addEventListener(Event.ID3, relayHandler);
		}
		
		override protected function removeListeners():void{

			mSound.removeEventListener(Event.COMPLETE, loadCompleteHandler);
			mSound.removeEventListener(ProgressEvent.PROGRESS, relayHandler);
			mSound.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler);
			mSound.removeEventListener(Event.ID3, relayHandler);

		}
		
		
			
		

		
		
		
	}
}

